package com.desire;

import com.desire.mapper.BookMapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootVersion;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author LittleDesire
 * @description
 * @date 2022-04-16 周六 11:26
 * @since 17
 */
@SpringBootApplication
@RestController
@MapperScan("com.desire.mapper")
@ComponentScan("com.desire.mapper")
public class App implements ApplicationRunner {

    @Value("${server.port}")
    int port;
    @Autowired
    BookMapper bm;
    @RequestMapping
    public String index() {
        return String.format("你好 %s,%s", SpringBootVersion.getVersion(),bm.selectList(null));
    }


    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        Runtime.getRuntime().exec("cmd /k start http://localhost:"+port);
    }
}
